package day20171130;

import java.sql.*;

/**
 * Created by Administrator on 2017-11-30.
 */
public class Test {


    public static void main(String[] args) {


        // 3 + 1

        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;


        String sql = "insert into students(id,username,password)" +
                "" +
                " values(2,'hello','123123123')";














        try {
            // 加载驱动程序
            Class.forName("com.mysql.jdbc.Driver");

            connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/test",
                    "root",
                    "123456"
            );

            statement = connection.createStatement();

            statement.execute(sql);

//            resultSet = statement.executeQuery(sql);
//
//            while (resultSet.next()) {
//
//                resultSet.getInt(1);
//                resultSet.getString(2);
//                resultSet.getString(3);
//            }

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {


            try {
                statement.close();
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }


    }
}
